package cn.stylefeng.guns.modular.gridsystem.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.gridsystem.model.param.CollectionModelParam;
import cn.stylefeng.guns.modular.gridsystem.service.CollectionModelService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * biz_collection_model 控制器
 *
 * @author: zxw
 * @date: 2022/11/01 15:32
 */
@RestController
@RequiredArgsConstructor
public class CollectionModelController {

    private final CollectionModelService collectionModelService;

    /**
     * 分页查询biz_collection_model
     *
     * @author zxw
     * @date 2022/11/01 15:32
     */
    @GetMapping("/collectionModel/page")
    @BusinessLog(title = "biz_collection_model_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CollectionModelParam collectionModelParam) {
        return new SuccessResponseData(collectionModelService.page(collectionModelParam));
    }

    /**
     * 获取全部biz_collection_model
     *
     * @author zxw
     * @date 2022/11/01 15:32
     */
    @GetMapping("/collectionModel/list")
    @BusinessLog(title = "biz_collection_model_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list( ) {
        return new SuccessResponseData(collectionModelService.list());
    }

    /**
     * 查看详情biz_collection_model
     *
     * @author zxw
     * @date 2022/11/01 15:32
     */
    @GetMapping("/collectionModel/detail")
    @BusinessLog(title = "biz_collection_model_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CollectionModelParam.detail.class) CollectionModelParam collectionModelParam) {
        return new SuccessResponseData(collectionModelService.detail(collectionModelParam));
    }

    /**
     * 添加biz_collection_model
     *
     * @author zxw
     * @date 2022/11/01 15:32
     */
    @PostMapping("/collectionModel/add")
    @BusinessLog(title = "biz_collection_model_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CollectionModelParam.add.class) CollectionModelParam collectionModelParam) {
        collectionModelService.add(collectionModelParam);
        return new SuccessResponseData();
    }

    /**
     * 删除biz_collection_model
     *
     * @author zxw
     * @date 2022/11/01 15:32
     */
    @PostMapping("/collectionModel/delete")
    @BusinessLog(title = "删除模型", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CollectionModelParam.delete.class) CollectionModelParam collectionModelParam) {
        collectionModelService.delete(collectionModelParam);
        return new SuccessResponseData();
    }

    /**
     * 同步采集端模型
     *
     * @author zxw
     * @date 2022/11/01 15:32
     */
    @PostMapping("/collectionModel/sync")
    @BusinessLog(title = "同步采集端模型", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData sync(@RequestBody @Validated(CollectionModelParam.sync.class) CollectionModelParam collectionModelParam) {
        return new SuccessResponseData(collectionModelService.sync(collectionModelParam));
    }

    /**
     * 编辑biz_collection_model
     *
     * @author zxw
     * @date 2022/11/01 15:32
     */
    @PostMapping("/collectionModel/edit")
    @BusinessLog(title = "biz_collection_model_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CollectionModelParam.edit.class) CollectionModelParam collectionModelParam) {
        collectionModelService.edit(collectionModelParam);
        return new SuccessResponseData();
    }

}
